# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-cantonese
pkgver=0.0.0.20230730
_commit=5a46116b4db00247bd7a576e8b29e86807c516ae
pkgrel=1
pkgdesc="Cantonese input for rime"
arch=('loong64' 'x86_64')
url="https://github.com/rime/rime-cantonese"
license=('CCPL:cc-by')
# dependency for reverse lookup
depends=('rime-cangjie' 'rime-emoji' 'rime-loengfan' 'rime-luna-pinyin' 'rime-stroke')
makedepends=('git' 'librime' 'rime-prelude' 'rime-essay')
source=("git+https://github.com/rime/rime-cantonese.git#commit=$_commit")
sha512sums=('SKIP')

prepare() {
  cd $pkgname
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname
  find . -type l -delete
  rm build/*.txt
  install -Dm644 *.txt *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
  install -Dm644 opencc/* -t "$pkgdir"/usr/share/rime-data/opencc/
}
